home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 331_01 / tprintf.c < prev   
Text File  |  1987-10-05  |  2KB  |  81 lines

  1. /*
  2. HEADER:     CUG999.14;
  3.  */
  4.  
  5. /* This function is used only for code development.  It need not be
  6.  * included in the link proceedure if not called.
  7.  *
  8.  * The text will appear on the second line in reverse field.
  9.  * The second line is reserved for the diagnostic data on the first call.
  10.  * Execution is suspended until the next keystroke so that the output
  11.  * can be read in case of back-to-back outputs.
  12.  *
  13.  * The variables a1-a8 are not simply related to the actual parameters.
  14.  * The code is a trick which copies the first 8 words of the argument
  15.  * list to sprintf.  The technique is moderately portable, but is outside
  16.  * the language defintion and is not used in the application code to
  17.  * insure portability.  tprintf is used exactly like printf, except that
  18.  * no newlines are needed and the number of arguments can't exceed 8 tyoe
  19.  * integer or 4 type long.
  20.  *
  21.  * far pointers can be printed with tprintf as %lx integers.  They appear
  22.  * in the form SEG:OFFSET.  The absolute memory address of a near pointer
  23.  * can be displayed by casting the pointer as type far.
  24.  *
  25.  * Another method of printing diagnostic output is to set topline to a value
  26.  * greater than 1 to reserve lines at the top, then use gotoxy() to position
  27.  * the cursor, (gotoxy(0,1) for the second line), then use printf in the
  28.  * conventional manner.  The last printf must be followed by a call to
  29.  * resetpcursor.
  30.  */
  31.  
  32. #include "ged.h"
  33.  
  34. /* print and hold a short time */
  35. tprintf(str,a1,a2,a3,a4,a5,a6,a7,a8)
  36. char *str, *a1, *a2, *a3, *a4, *a5, *a6,*a7,*a8;
  37. {
  38.     char buf[81];
  39.     int j;
  40.     long i;
  41.  
  42. /* reserve an additional line at the top.  help display assumed off */
  43.     if(topline == 1) {
  44.         topline = 2;
  45.         calp();
  46. /* a call to putpage here would be proper but might compiicate troubleshooting
  47.  * too much.
  48.  */
  49.     }
  50.  
  51.     for (j=0; j<80; j++)
  52.         buf[j]=' ';
  53.     buf[79]=0;
  54.     scr_aputs(0,1,buf,ATTR0);
  55.     sprintf(buf,str,a1,a2,a3,a4,a5,a6,a7,a8);
  56.     scr_aputs(0,1,buf,ATTR2);
  57.     for (i = 0; i < 25000L; i++);
  58.     return;
  59. }
  60.  
  61. /* print and hold */
  62.  
  63. hprintf(str,a1,a2,a3,a4,a5,a6,a7,a8)
  64. char *str, *a1, *a2, *a3, *a4, *a5;
  65. {
  66.     int i;
  67. i = chkbuf();
  68.     tprintf(str,a1,a2,a3,a4,a5,a6,a7,a8);
  69. /* Wait for any key. */
  70.     while (chkbuf() == i)
  71.         ;
  72.     inbufp =0;
  73.     scr_aputs(78,1," ",ATTR2);  /* acknowledge the key. it is used normally. */
  74.     return;
  75. }
  76.  
  77.  
  78.  
  79.  
  80.  
  81.